﻿@{
    Uri url = new Uri(Request.Url.AbsoluteUri);
    ViewBag.Title = "Home";
    string RafikiMasterVM = System.Configuration.ConfigurationManager.AppSettings["RafikiMasterVM"];
    string crudServiceBaseUrl = ViewBag.Server + "/api/";

    // Code to check for expired IN-HOUSE accounts:
    if (!User.Identity.Name.Contains("@") && Request.IsAuthenticated && url.AbsolutePath != "/Manage/ChangePassword")
    {
        ADFuncs ADQuery = new ADFuncs();
        ViewBag.DaysBeforeExpiring = ADQuery.GetUserPasswordExpiration(User.Identity.Name).Subtract(DateTime.Today).Days;
    }
    else
    {
        ViewBag.DaysBeforeExpiring = 1000;
    }
}

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - Portal.rva.org</title>

    @* Scripts: bowser checks browser funtion, essential Kendo and Jquery *@
    <script src="~/Scripts/bowser.min.js"></script>
    <script src="~/Scripts/jquery-2.1.1.min.js"></script>
    <script src="~/Scripts/kendo/2014.3.1119/kendo.core.min.js"></script>
    <script src="~/Scripts/kendo/2014.3.1119/kendo.data.min.js"></script>
    <script src="~/Scripts/kendo/2014.3.1119/kendo.binder.min.js"></script>
    <script src="~/Scripts/kendo/2014.3.1119/kendo.menu.min.js"></script>
    @* The following is custom javascript - probably should be renamed because it is becoming helpful for more than ShowEntity *@
    <script src="~/Scripts/ShowEntityJScript.js"></script>
    @* The following is a poly fill for Internet Explorer to help our header work nicer. *@
    <script src="~/Scripts/pointer_events_polyfill.js"></script>
    <!-- Tab/Accordion Functions from Vesa Piittinen -->
    <link href="~/Content/MeyerReset.css" rel="stylesheet" />
    <link href="~/Content/Normalize.css" rel="stylesheet" />
    <link href="~/Content/RafikiCore.css" rel="stylesheet" />
    <script src="~/Scripts/Tab-Accordion-IE.js"></script>
    <link href="~/Content/kendo/2014.3.1119/kendo.common-bootstrap.core.min.css" rel="stylesheet" />
    <link href="~/Content/kendo/2014.3.1119/kendo.common.core.min.css" rel="stylesheet" />
    <!-- Top Level View Model javascript commands -->
    <script>
        window.onerror = function() {
            alert("There was some sort of error. Most likely if you refresh the page, everything will be ok. If you keep seeing this message, email portalhelp@rva.org");
        };

        if (!bowser.a)
            alert("Your browser may not be the latest or it may be limited in some way. Portal might be fine, but it could be less predictable in some way. Whenever possible it is best to run the latest version of Firefox or Chrome.");

        @(RafikiMasterVM) = kendo.observable({
             userEntityID: "@HttpUtility.JavaScriptStringEncode((string)Session["AuthUserPersonID"])",
                 userName: "@HttpUtility.JavaScriptStringEncode((string)Session["AuthUserFullName"])",
            messageSource: new kendo.data.DataSource({ // pick up messages to display or to update system
                transport: {
                    read: {
                        url: "@crudServiceBaseUrl" + "alltables/message",
                        dataType: "json"
                    }
                }
            })
        });
    </script>
</head>
<body>
    <div id="header">

    </div>
    @Html.Partial("_LoginPartial")

    <div id="content">
        @RenderBody()

    </div>

    @if (ViewBag.DaysBeforeExpiring < 31 && ViewBag.DaysBeforeExpiring >= 0)
    {
        <div class="centercontent">
            <h4>Your Password will expire in @ViewBag.DaysBeforeExpiring days. <a href="@Url.Action("ChangePassword", "Manage")" title="Change Your Password">Click Here to change your password.</a></h4>
        </div>
    }
    else if (ViewBag.DaysBeforeExpiring < 0)
    {
        <div class="centercontent">
            <h4>Your Password has expired. <a href="@Url.Action("ChangePassword", "Manage")" title="Change Your Password">Click Here to change your password.</a></h4>
            @ViewBag.URL
        </div>
    }

    <div id="footer">
        <p>&copy; @DateTime.Now.Year   This portal is still under development, email <a href="mailto:portalhelp@rva.org">portalhelp@rva.org</a> if you experience difficulties.</p>
    </div>


    @RenderSection("scripts", required: false)

</body>
</html>
